package com.seteam.collabcrossword.messages.server;

import com.seteam.collabcrossword.Globals;
import com.seteam.collabcrossword.Tile;
import com.seteam.collabcrossword.messages.Message;

import java.io.Serializable;

/**
 * This message is used by the server to send out the current state
 * of the crossword. The clients need to override the current state before
 * displaying the solution. This is to ensure that both players have the
 * same current state on their boards before they see the solution
 */
public class CurrentState implements Message, Serializable {
    private static final long serialVersionUID = 857445095713248705L;
    private Object[][] currentState;

    /**
     * Constructor
     *
     * @param currentState the array of tiles that represents the current state of the
     *                     crossword
     */
    public CurrentState(final Tile[][] currentState) {
        this.currentState = new Tile[currentState.length][currentState[0].length];
        this.currentState = currentState;
    }

    /**
     * Getter for currentState
     *
     * @return the array of tiles that represents the current state of the crossword
     */
    public Tile[][] getCurrentState() {
        return (Tile[][]) currentState;
    }

    /**
     * {@inheritDoc}
     */
    public String getAction() {
        return Globals.CURRENT_STATE;
    }
}
